package com.kt.springcloud.controller;

import com.kt.springcloud.entity.ApiResult;
import com.kt.springcloud.entity.Payment;
import com.kt.springcloud.service.OrderFeign;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author DengXin
 * @date 2022/10/5 19:18
 */
@RestController
public class OrderFeignCtrl {
    @Resource
    private OrderFeign orderFeign;

    @GetMapping(value = "/consumer/payment/{id}")
    public ApiResult<Payment> get(@PathVariable("id") Long id) {
        return orderFeign.getPaymentById(id);
    }

    @GetMapping(value = "/consumer/payment/feign/timeout")
    public String paymentFeignTimeout() {
        // OpenFeign-Ribbon，客户端一般默认等待1秒钟
        return orderFeign.paymentFeignTimeout();
    }
}
